' Read File
' This program demonstrates use of the INPUT# statement to get
'   data from a sequential file.

CLS

OPEN "Friend.Data" FOR OUTPUT AS #1  ' open file for output

PRINT "Enter the names of four of your friends."
PRINT

FOR i% = 1 TO 4                      ' loop 4 times
    INPUT "Friendly name:  ", pal$   ' each time, get name from user
    WRITE #1, pal$                          '   and write it to disk
NEXT i%

CLOSE #1                               ' close the file

OPEN "Friend.data" FOR INPUT AS #1   ' reopen the file for input

PRINT
PRINT "You entered the following names:"
PRINT

FOR i% = 1 TO 4                    ' loop 4 times
    INPUT #1, pal$                 ' each time, get name from file
    PRINT pal$                       '   and display it on screen
NEXT i%

CLOSE #1                             ' close the file

PRINT
INPUT "Press Return to continue", dummy$